package com.example.mobile2021606159yhf0427;


import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class rv_main_list extends RecyclerView.Adapter<rv_main_list.ViewHolder>{
      private List<Tingchechang>list;
      public rv_main_list(List<Tingchechang>list){
          this.list=list;
      }
  @NonNull
  @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
          View view = LinearLayout.from(parent.getContext()).inflate(R.id.tv_main_tingchechang
          ,parent,false);
       return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
          Tingchechang tingchechang = list.get(position);
          holder.tvMaintingchechang.setText(tingchechang.gettvMaintingchechang());
          holder.tvMainkongwei.setText(String.valueOf(tingchechang.getTvMainkongwei()));
          holder.tvMainjuli.setText(tingchechang.getTvMainjuli());
          holder.tvMainjiage.setText(tingchechang.getTvMainjiage());
          holder.tvMaindizhi.setText(tingchechang.getTvMaindizhi());
          holder.tvMainother.setText(tingchechang.getOther());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView tvMaintingchechang,tvMainjiage,tvMainjuli,tvMaindizhi,tvMainkongwei,tvMainother;
        ImageView ivMaintupian;
        public ViewHolder(@NonNull View itemView){
            super(itemView);
            tvMaintingchechang = itemView.findViewById(R.id.tv_main_tingchechang);
            tvMaindizhi = itemView.findViewById(R.id.tv_main_dizhi);
            tvMainjiage = itemView.findViewById(R.id.tv_main_jiage);
            tvMainjuli = itemView.findViewById(R.id.tv_main_juli);
            tvMainkongwei = itemView.findViewById(R.id.tv_main_kongwei);
            tvMainother = itemView.findViewById(R.id.tv_main_other);
            ivMaintupian = itemView.findViewById(R.id.iv_main_tupian);
        }
    }
}
